package com.samphanie.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;

import java.security.KeyPair;

/**
 * 读取授权密匙
 * @author Dries
 * @email 1451691457@qq.com
 */
@Configuration
public class KeyPairConfig {

    @Bean
    public KeyPair keyPair() {
        ClassPathResource ksFile = new ClassPathResource("jwt.jks");
        KeyStoreKeyFactory ksFactory = new KeyStoreKeyFactory(ksFile, "123456".toCharArray());
        return ksFactory.getKeyPair("jwt");
    }

}
